<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/11 0011
  Time: 下午 4:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>

    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
</head>
<body>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>




<table class="layui-table" lay-data="{ url:'/member/sonMemberData?parentId=${id}', page:true, id:'idTest'}" lay-filter="demo">
    <thead>
    <tr>
        <%--<th lay-data="{type:'checkbox', fixed: 'left'}"></th>--%>
        <th lay-data="{field:'name',width:260 }">会员名称</th>
        <th lay-data="{field:'grade', width:100}">会员等级</th>
        <th lay-data="{field:'rebateMoney', width:100}">获得的返利</th>
        <th lay-data="{field:'oneSonMember', width:100}">一级下级会员</th>
        <th lay-data="{field:'twoSonMember', width:100}">二级下级会员</th>
        <th lay-data="{field:'accountMoney', width:100}">账户余额</th>
        <th lay-data="{field:'createTime', width:180 }">创建时间</th>
        <th lay-data="{fixed: 'right',  width:100, align:'center', toolbar: '#sonMember'}">下级会员</th>
        <th lay-data="{fixed: 'right',  width:100, align:'center', toolbar: '#rebateMoney'}">返利记录</th>
        <th lay-data="{fixed: 'right',  width:100, align:'center', toolbar: '#accountInfo'}">账户记录</th>

    </tr>
    </thead>
</table>



<script type="text/html" id="sonMember">
    <a class="layui-btn layui-btn-xs" lay-event="sonMember" >下级详情</a>
</script>
<script type="text/html" id="rebateMoney">
    <a class="layui-btn layui-btn-xs" lay-event="rebateMoney" >返利记录</a>
</script>

<script type="text/html" id="accountInfo">
    <a class="layui-btn layui-btn-xs" lay-event="accountInfo" >订单详情</a>
</script>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>

    layui.use('element', function(){
        var element = layui.element;
    });

    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj);
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            }else if(obj.event === 'sonMember'){//
                layer.open({
                    type: 2,
                    title:obj.data.name+"             的下级会员",
                    shadeClose:true,
                    offset: '0px',
                    area: ['95%', '90%'],
                    content: '/member/sonMember?id='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }else if (obj.event=='rebateMoney'){//返利记录
                layer.open({
                    type: 2,
                    title:obj.data.name+"             的返利记录",
                    shadeClose:true,
                    area: ['90%', '90%'],
                    offset: '0px',
                    content: '/member/memberRebateLog?memberId='+obj.data.id,
                    end:function () {
                        window.location.reload();
                    }
                });
            }else if (obj.event=='accountInfo') {//账户记录
                layer.open({
                    type: 2,
                    title: obj.data.name + "             的账户记录",
                    shadeClose: true,
                    offset: '0px',
                    area: ['95%', '95%'],
                    content: '/member/memberAccountLog?memberId=' + obj.data.id,
                    end: function () {
                        window.location.reload();
                    }
                });
            }
    });
        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    /*添加机构*/
    function addShop() {
        $.cookie("orgDate",null);
        layer.open({
            type: 2,
            title:"机构信息",
            shadeClose:true,
            offset: '30px',
            area: ['75%', '75%'],
            content: '/shop/goShopInfo?id=',
            end:function () {
                window.location.reload();
            }
        });
    }



</script>





</body>
</html>
